package com.prolestar.web.controller.partyConstruction;


import com.prolestar.common.annotation.Log;
import com.prolestar.common.core.controller.BaseController;
import com.prolestar.common.core.domain.AjaxResult;
import com.prolestar.common.core.page.TableDataInfo;
import com.prolestar.common.enums.BusinessType;
import com.prolestar.partyConstruction.domain.PsCompanyPartyinfo;
import com.prolestar.partyConstruction.domain.PsCompanypartyActivites;
import com.prolestar.partyConstruction.service.IPartyConstructionService;
import com.prolestar.util.MySetPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 党建模块
 */
@RestController
@RequestMapping("/partyConstruction/partyConstruction")
public class PartyConstructionController extends BaseController {
    @Autowired
    private IPartyConstructionService partyConstructionService;

    /**
     * 查询党建列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PsCompanyPartyinfo psCompanyPartyinfo)
    {
        List<PsCompanyPartyinfo> list = partyConstructionService.selectpartyConstructionList(psCompanyPartyinfo);
        return MySetPage.mySetPage(list);
    }


    /**
     * 获取党建详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(partyConstructionService.selectPartyConstructionById(id));
    }
    /**
     * 获取三会一课详细信息
     */
    @GetMapping(value = "/getPcaInfo/{id}")
    public AjaxResult getPcaInfo(@PathVariable("id") Long id)
    {
        return success(partyConstructionService.getPcaInfo(id));
    }

    /**
     * 新增党建
     */
    @Log(title = "党建", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PsCompanyPartyinfo psCompanyPartyinfo)
    {
        partyConstructionService.insertPsCompanyPartyinfo(psCompanyPartyinfo);
        return AjaxResult.success();
    }

    /**
     * 新增三会一课
     */
    @Log(title = "党建", businessType = BusinessType.INSERT)
    @PostMapping("/addPC")
    public AjaxResult addPsCompanypartyActivites(@RequestBody PsCompanypartyActivites psCompanypartyActivites)
    {
        return partyConstructionService.insertpsCompanypartyActivites(psCompanypartyActivites);
    }

    /**
     * 修改党建
     */
    @Log(title = "党建", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PsCompanyPartyinfo psCompanyPartyinfo)
    {
        return partyConstructionService.updatePsCompanyPartyinfo(psCompanyPartyinfo);
    }
    /**
     * 修改三会一课
     */
    @Log(title = "党建", businessType = BusinessType.UPDATE)
    @PutMapping("/updatePC")
    public AjaxResult editPC(@RequestBody PsCompanypartyActivites PsCompanypartyActivites)
    {
        return partyConstructionService.updatepsCompanypartyActivites(PsCompanypartyActivites);
    }

    /**
     * 删除党建
     */
    @Log(title = "党建", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return partyConstructionService.deletePsCompanyPartyinfo(ids);
    }
    /**
     * 删除三会一课
     */
    @Log(title = "党建", businessType = BusinessType.DELETE)
    @DeleteMapping("delPca/{ids}")
    public AjaxResult removePca(@PathVariable Long[] ids)
    {
        return partyConstructionService.removePca(ids);
    }





}
